#ifndef __SLOTHTTPD_CONFIG_LOCATION_LOCATION_HPP__
#define __SLOTHTTPD_CONFIG_LOCATION_LOCATION_HPP__

#include <slothttpd/connection.hpp>
#include <slothttpd/config/create_matcher.hpp>

#include <cstddef>
#include <string>
#include <vector>
#include <ostream>

#include <boost/shared_ptr.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/asio/buffer.hpp>

namespace slothttpd {
namespace config {

class server;

class base_location;
typedef boost::shared_ptr<base_location> location_ptr;

class base_location
{
public:
    base_location(const boost::property_tree::ptree &node, server &s);
    virtual ~base_location();
    
    bool match_path(char_range_t path) const;
    virtual void apply(connection_ptr c) = 0;
    
public:
    server                     &loc_server;
    
    std::vector<std::string>    match_patters;
    std::vector<matcher_type>   match;
    std::string                 dest;
    std::string                 path;
    std::vector<std::string>    headers;
    std::vector<boost::asio::const_buffer> header_buffers;
};

std::ostream &operator<<(std::ostream &os, const base_location &loc);

}
}

#endif
